package root.electronclass.electronclass.grade.model

import android.os.Parcelable
import android.text.Html
import root.electronclass.electronclass.mvp.GlobalParameter
import kotlinx.parcelize.Parcelize
import java.math.BigDecimal

/**
 *
 * @author Lokiy
 * @date 2023/3/25 15:43
 */

data class PersonalAttendanceStatQuery(
    val pageNo: Int,
    val type: Int,//1-7天 2-一个月 3-一学期
    val pageSize: Int = 20,
    val departId: String = GlobalParameter.getEcardInfo().classId.toString(),
    val schoolId: String = GlobalParameter.getEcardInfo().schoolId.toString(),
    val userId: String = GlobalParameter.getSTUDENT()?.id.toString(),
)

@Parcelize
data class AttendanceReport(
    val id: String,
    val afternoonStatus: Int,//0-未打卡 1-正常 2-迟到 3-早退 4-旷工
    val morningStatus: Int,//0-未打卡 1-正常 2-迟到 3-早退 4-旷工
    val noonStatus: Int,//0-未打卡 1-正常 2-迟到 3-早退 4-旷工
    val eveningStatus: Int,//0-未打卡 1-正常 2-迟到 3-早退 4-旷工
    val earlyLeaveTime: Int,
    val latenessTime: Int,
    val statDate: String,//创建时间
    val name: String,//姓名
    val departName: String,//班级
    val userNo: String,//创建时间
) : Parcelable {

    fun getSignText(status: Int): CharSequence {
        val (color, text) = when (status) {
            1 -> "#071129" to "已打卡"
            2 -> "#FF503D" to "迟到 %d分钟".format(latenessTime)
            3 -> "#FF503D" to "早退 %d分钟".format(earlyLeaveTime)
            4 -> "#FF503D" to "旷工"
            else -> "#FF503D" to "未打卡"
        }
        @Suppress("DEPRECATION")
        return Html.fromHtml("<font color='%s'>%s</font>".format(color, text))
    }
}

/**
 * 考勤统计
 */
data class AttendanceStat(
    val actualDay: Int,
    val compassionateLeave: Int,//事假
    val late: Int,//迟到
    val leaveEarly: Int,//早退
    val other: Int,//其他
    val sickLeave: Int,//病假
    val totalDay: Int,//统计天数
    val truancy: Int,//旷课
)

@Parcelize
data class AttendanceInfo(
    val cardNo: String,
    val codeType: Int,//健康码状态,0-无码；1-绿码；2-黄码；3-红码；4-其他
    val doorName: String?,//门禁点
    val name: String?,//姓名
    val picUrl: String,//图片地址
    val temperature: String?,
    val departName: String?,//班级
    val userNo: String?,//创建时间
    var urls: Array<String>,
) : Parcelable

/**
 * 个人消费记录查询
 */
data class StuPayRecordQuery(
    val pageNo: Int,
    val orderType: String?,//消费类目: 充值,在线点餐,学校补助,退单,消费机扣款,退费,海康线下扣款,交易冲正,临时充值
    val startTime: String,
    val endTime: String,
    val pageSize: Int = 20,
    val departId: String = GlobalParameter.getEcardInfo().classId.toString(),
    val schoolId: String = GlobalParameter.getEcardInfo().schoolId.toString(),
    val userId: String = GlobalParameter.getSTUDENT()?.id.toString(),
)

data class CanteenPayRecord(
    val balance: String,
    val eventTime: String,
    val deviceName: String?,//消费机名称
    val orderName: String?,//消费名称
    val orderType: String,//消费类目
    val price: String,//消费金额
    val tranNo: String,//消费流水号
    val iscStatus: Int,//isc扣款是否成功 1-成功 2-失败
)

data class CanteenStatUser(
    val offline: BigDecimal?,//线下消费金额
    val online: BigDecimal?,//线上消费金额
    val statDate: String,//统计日期
)